/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package resourceCache;

// import javax.
import utilities.Cache;

/**
 *
 * @author Mike
 */
public class ResourceCache<K, V> {

    private ResourceCache rCache;
    private Cache<K, V> cache;

    private ResourceCache() {
        cache = new Cache<>(100);
    }

    public ResourceCache getInstance() {
        if (rCache == null) {
            rCache = new ResourceCache();
        }

        return rCache;
    }

    public void add(K key, V value) {
        cache.put(key, value);
    }

    public V get(K key) {
        return cache.get(key);
    }

    public int size() {
        return cache.size();
    }

    public boolean clear() {
        boolean cleared = false;
        if (cache.size() == 0) {
            cleared = true;
        } else {
            cache.clear();
            cleared = true;
        }
        return cleared;
    }
}
